// 聊天模块 - 处理聊天相关操作
import baseAPI from './base.js'

class ChatAPI {
    // 获取用户房间列表
    async getUserRooms(userId) {
        return baseAPI.request(`/chat/rooms?user_id=${userId}`, { 
            method: 'GET' 
        });
    }

    // 创建房间
    async createRoom({ userId, roomId, roomName, roomType = 'private' }) {
        return baseAPI.request('/chat/rooms', {
            method: 'POST',
            body: JSON.stringify({ 
                user_id: userId, 
                room_id: roomId, 
                room_name: roomName, 
                room_type: roomType 
            })
        });
    }

    // 获取聊天消息（使用 baseAPI.get）
    async getChatMessages(roomId) {
        return baseAPI.get(`/chat/messages?room_id=${encodeURIComponent(roomId)}`);
    }

    // 获取好友信息（聊天相关）
    async getFriendInfo(userId) {
        return baseAPI.get(`/friends/${userId}`);
    }
}

// 创建全局实例
const chatAPI = new ChatAPI();

export default chatAPI; 